//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS PcaConnectorScep service.
///
/// Connector for SCEP creates a connector between Amazon Web Services Private CA and your SCEP-enabled clients and devices. For more information, see Connector for SCEP in the Amazon Web Services Private CA User Guide.
public struct PcaConnectorScep: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the PcaConnectorScep client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "PcaConnectorScep",
            serviceIdentifier: "pca-connector-scep",
            serviceProtocol: .restjson,
            apiVersion: "2018-05-10",
            endpoint: endpoint,
            errorType: PcaConnectorScepErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// For general-purpose connectors. Creates a challenge password for the specified connector. The SCEP protocol uses a challenge password to authenticate a request before issuing a certificate from a certificate authority (CA). Your SCEP clients include the challenge password as part of their certificate request to Connector for SCEP. To retrieve the connector Amazon Resource Names (ARNs) for the connectors in your account, call ListConnectors. To create additional challenge passwords for the connector, call CreateChallenge again. We recommend frequently rotating your challenge passwords.
    @Sendable
    @inlinable
    public func createChallenge(_ input: CreateChallengeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateChallengeResponse {
        try await self.client.execute(
            operation: "CreateChallenge", 
            path: "/challenges", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// For general-purpose connectors. Creates a challenge password for the specified connector. The SCEP protocol uses a challenge password to authenticate a request before issuing a certificate from a certificate authority (CA). Your SCEP clients include the challenge password as part of their certificate request to Connector for SCEP. To retrieve the connector Amazon Resource Names (ARNs) for the connectors in your account, call ListConnectors. To create additional challenge passwords for the connector, call CreateChallenge again. We recommend frequently rotating your challenge passwords.
    ///
    /// Parameters:
    ///   - clientToken: Custom string that can be used to distinguish between calls to the CreateChallenge action. Client tokens for CreateChallenge time out after five minutes. Therefore, if you call CreateChallenge multiple times with the same client token within five minutes, Connector for SCEP recognizes that you are requesting only one challenge and will only respond with one. If you change the client token for each call, Connector for SCEP recognizes that you are requesting multiple challenge passwords.
    ///   - connectorArn: The Amazon Resource Name (ARN) of the connector that you want to create a challenge for.
    ///   - tags: The key-value pairs to associate with the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func createChallenge(
        clientToken: String? = CreateChallengeRequest.idempotencyToken(),
        connectorArn: String,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateChallengeResponse {
        let input = CreateChallengeRequest(
            clientToken: clientToken, 
            connectorArn: connectorArn, 
            tags: tags
        )
        return try await self.createChallenge(input, logger: logger)
    }

    /// Creates a SCEP connector. A SCEP connector links Amazon Web Services Private Certificate Authority to your SCEP-compatible devices and mobile device management (MDM) systems. Before you create a connector, you must complete a set of prerequisites, including creation of a private certificate authority (CA) to use with this connector. For more information, see Connector for SCEP prerequisites.
    @Sendable
    @inlinable
    public func createConnector(_ input: CreateConnectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateConnectorResponse {
        try await self.client.execute(
            operation: "CreateConnector", 
            path: "/connectors", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates a SCEP connector. A SCEP connector links Amazon Web Services Private Certificate Authority to your SCEP-compatible devices and mobile device management (MDM) systems. Before you create a connector, you must complete a set of prerequisites, including creation of a private certificate authority (CA) to use with this connector. For more information, see Connector for SCEP prerequisites.
    ///
    /// Parameters:
    ///   - certificateAuthorityArn: The Amazon Resource Name (ARN) of the Amazon Web Services Private Certificate Authority certificate authority to use with this connector. Due to security vulnerabilities present in the SCEP protocol, we recommend using a private CA that's dedicated for use with the connector. To retrieve the private CAs associated with your account, you can call ListCertificateAuthorities using the Amazon Web Services Private CA API.
    ///   - clientToken: Custom string that can be used to distinguish between calls to the CreateChallenge action. Client tokens for CreateChallenge time out after five minutes. Therefore, if you call CreateChallenge multiple times with the same client token within five minutes, Connector for SCEP recognizes that you are requesting only one challenge and will only respond with one. If you change the client token for each call, Connector for SCEP recognizes that you are requesting multiple challenge passwords.
    ///   - mobileDeviceManagement: If you don't supply a value, by default Connector for SCEP creates a connector for general-purpose use. A general-purpose connector is designed to work with clients or endpoints that support the SCEP protocol, except Connector for SCEP for Microsoft Intune. With connectors for general-purpose use, you manage SCEP challenge passwords using Connector for SCEP. For information about considerations and limitations with using Connector for SCEP, see Considerations and Limitations. If you provide an IntuneConfiguration, Connector for SCEP creates a connector for use with Microsoft Intune, and you manage the challenge passwords using Microsoft Intune. For more information, see Using Connector for SCEP for Microsoft Intune.
    ///   - tags: The key-value pairs to associate with the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func createConnector(
        certificateAuthorityArn: String,
        clientToken: String? = CreateConnectorRequest.idempotencyToken(),
        mobileDeviceManagement: MobileDeviceManagement? = nil,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateConnectorResponse {
        let input = CreateConnectorRequest(
            certificateAuthorityArn: certificateAuthorityArn, 
            clientToken: clientToken, 
            mobileDeviceManagement: mobileDeviceManagement, 
            tags: tags
        )
        return try await self.createConnector(input, logger: logger)
    }

    /// Deletes the specified Challenge.
    @Sendable
    @inlinable
    public func deleteChallenge(_ input: DeleteChallengeRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "DeleteChallenge", 
            path: "/challenges/{ChallengeArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes the specified Challenge.
    ///
    /// Parameters:
    ///   - challengeArn: The Amazon Resource Name (ARN) of the challenge password to delete.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteChallenge(
        challengeArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = DeleteChallengeRequest(
            challengeArn: challengeArn
        )
        return try await self.deleteChallenge(input, logger: logger)
    }

    /// Deletes the specified Connector. This operation also deletes any challenges associated with the connector.
    @Sendable
    @inlinable
    public func deleteConnector(_ input: DeleteConnectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "DeleteConnector", 
            path: "/connectors/{ConnectorArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes the specified Connector. This operation also deletes any challenges associated with the connector.
    ///
    /// Parameters:
    ///   - connectorArn: The Amazon Resource Name (ARN) of the connector to delete.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteConnector(
        connectorArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = DeleteConnectorRequest(
            connectorArn: connectorArn
        )
        return try await self.deleteConnector(input, logger: logger)
    }

    /// Retrieves the metadata for the specified Challenge.
    @Sendable
    @inlinable
    public func getChallengeMetadata(_ input: GetChallengeMetadataRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetChallengeMetadataResponse {
        try await self.client.execute(
            operation: "GetChallengeMetadata", 
            path: "/challengeMetadata/{ChallengeArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the metadata for the specified Challenge.
    ///
    /// Parameters:
    ///   - challengeArn: The Amazon Resource Name (ARN) of the challenge.
    ///   - logger: Logger use during operation
    @inlinable
    public func getChallengeMetadata(
        challengeArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetChallengeMetadataResponse {
        let input = GetChallengeMetadataRequest(
            challengeArn: challengeArn
        )
        return try await self.getChallengeMetadata(input, logger: logger)
    }

    /// Retrieves the challenge password for the specified Challenge.
    @Sendable
    @inlinable
    public func getChallengePassword(_ input: GetChallengePasswordRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetChallengePasswordResponse {
        try await self.client.execute(
            operation: "GetChallengePassword", 
            path: "/challengePasswords/{ChallengeArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the challenge password for the specified Challenge.
    ///
    /// Parameters:
    ///   - challengeArn: The Amazon Resource Name (ARN) of the challenge.
    ///   - logger: Logger use during operation
    @inlinable
    public func getChallengePassword(
        challengeArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetChallengePasswordResponse {
        let input = GetChallengePasswordRequest(
            challengeArn: challengeArn
        )
        return try await self.getChallengePassword(input, logger: logger)
    }

    /// Retrieves details about the specified Connector. Calling this action returns important details about the connector, such as the public SCEP URL where your clients can request certificates.
    @Sendable
    @inlinable
    public func getConnector(_ input: GetConnectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetConnectorResponse {
        try await self.client.execute(
            operation: "GetConnector", 
            path: "/connectors/{ConnectorArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves details about the specified Connector. Calling this action returns important details about the connector, such as the public SCEP URL where your clients can request certificates.
    ///
    /// Parameters:
    ///   - connectorArn: The Amazon Resource Name (ARN) of the connector.
    ///   - logger: Logger use during operation
    @inlinable
    public func getConnector(
        connectorArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetConnectorResponse {
        let input = GetConnectorRequest(
            connectorArn: connectorArn
        )
        return try await self.getConnector(input, logger: logger)
    }

    /// Retrieves the challenge metadata for the specified ARN.
    @Sendable
    @inlinable
    public func listChallengeMetadata(_ input: ListChallengeMetadataRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListChallengeMetadataResponse {
        try await self.client.execute(
            operation: "ListChallengeMetadata", 
            path: "/challengeMetadata", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the challenge metadata for the specified ARN.
    ///
    /// Parameters:
    ///   - connectorArn: The Amazon Resource Name (ARN) of the connector.
    ///   - maxResults: The maximum number of objects that you want Connector for SCEP to return for this request. If more objects are available, in the response, Connector for SCEP provides a NextToken value that you can use in a subsequent call to get the next batch of objects.
    ///   - nextToken: When you request a list of objects with a MaxResults setting, if the number of objects that are still available for retrieval exceeds the maximum you requested, Connector for SCEP returns a NextToken value in the response. To retrieve the next batch of objects, use the token returned from the prior request in your next request.
    ///   - logger: Logger use during operation
    @inlinable
    public func listChallengeMetadata(
        connectorArn: String,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListChallengeMetadataResponse {
        let input = ListChallengeMetadataRequest(
            connectorArn: connectorArn, 
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listChallengeMetadata(input, logger: logger)
    }

    /// Lists the connectors belonging to your Amazon Web Services account.
    @Sendable
    @inlinable
    public func listConnectors(_ input: ListConnectorsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListConnectorsResponse {
        try await self.client.execute(
            operation: "ListConnectors", 
            path: "/connectors", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists the connectors belonging to your Amazon Web Services account.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of objects that you want Connector for SCEP to return for this request. If more objects are available, in the response, Connector for SCEP provides a NextToken value that you can use in a subsequent call to get the next batch of objects.
    ///   - nextToken: When you request a list of objects with a MaxResults setting, if the number of objects that are still available for retrieval exceeds the maximum you requested, Connector for SCEP returns a NextToken value in the response. To retrieve the next batch of objects, use the token returned from the prior request in your next request.
    ///   - logger: Logger use during operation
    @inlinable
    public func listConnectors(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListConnectorsResponse {
        let input = ListConnectorsRequest(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listConnectors(input, logger: logger)
    }

    /// Retrieves the tags associated with the specified resource. Tags are key-value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each Amazon Web Services resource, up to 50 tags for a resource.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the tags associated with the specified resource. Tags are key-value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each Amazon Web Services resource, up to 50 tags for a resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Adds one or more tags to your resource.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds one or more tags to your resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - tags: The key-value pairs to associate with the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [String: String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes one or more tags from your resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes one or more tags from your resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - tagKeys: Specifies a list of tag keys that you want to remove from the specified resources.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }
}

extension PcaConnectorScep {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: PcaConnectorScep, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension PcaConnectorScep {
    /// Return PaginatorSequence for operation ``listChallengeMetadata(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listChallengeMetadataPaginator(
        _ input: ListChallengeMetadataRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListChallengeMetadataRequest, ListChallengeMetadataResponse> {
        return .init(
            input: input,
            command: self.listChallengeMetadata,
            inputKey: \ListChallengeMetadataRequest.nextToken,
            outputKey: \ListChallengeMetadataResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listChallengeMetadata(_:logger:)``.
    ///
    /// - Parameters:
    ///   - connectorArn: The Amazon Resource Name (ARN) of the connector.
    ///   - maxResults: The maximum number of objects that you want Connector for SCEP to return for this request. If more objects are available, in the response, Connector for SCEP provides a NextToken value that you can use in a subsequent call to get the next batch of objects.
    ///   - logger: Logger used for logging
    @inlinable
    public func listChallengeMetadataPaginator(
        connectorArn: String,
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListChallengeMetadataRequest, ListChallengeMetadataResponse> {
        let input = ListChallengeMetadataRequest(
            connectorArn: connectorArn, 
            maxResults: maxResults
        )
        return self.listChallengeMetadataPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listConnectors(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listConnectorsPaginator(
        _ input: ListConnectorsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListConnectorsRequest, ListConnectorsResponse> {
        return .init(
            input: input,
            command: self.listConnectors,
            inputKey: \ListConnectorsRequest.nextToken,
            outputKey: \ListConnectorsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listConnectors(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults: The maximum number of objects that you want Connector for SCEP to return for this request. If more objects are available, in the response, Connector for SCEP provides a NextToken value that you can use in a subsequent call to get the next batch of objects.
    ///   - logger: Logger used for logging
    @inlinable
    public func listConnectorsPaginator(
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListConnectorsRequest, ListConnectorsResponse> {
        let input = ListConnectorsRequest(
            maxResults: maxResults
        )
        return self.listConnectorsPaginator(input, logger: logger)
    }
}

extension PcaConnectorScep.ListChallengeMetadataRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> PcaConnectorScep.ListChallengeMetadataRequest {
        return .init(
            connectorArn: self.connectorArn,
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}

extension PcaConnectorScep.ListConnectorsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> PcaConnectorScep.ListConnectorsRequest {
        return .init(
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}
